<?php
session_start ();
$query_remplissage_score_SPRS = "UPDATE `$db`.`diagnostic` SET `score_SPRS` = '$score_SPRS' WHERE `diagnostic`.`form` = " . $_SESSION ['form'];
mysql_query ( $query_remplissage_score_SPRS ) or die ( "impossible de remplir le score SPRS : " . mysql_error () );
// ~ mysqli_query($query_remplissage_score_SPRS) or die("impossible de remplir le score SPRS : " . mysql_error());

// remplissage des valeurs dans la table SPRS
if (isset ( $_POST ['walk'] )) {
	$walk = $_POST ['walk'];
} else {
	$walk = '';
}
if (isset ( $_POST ['gait'] )) {
	$gait = $_POST ['gait'];
} else {
	$gait = '';
}
if (isset ( $_POST ['gait_speed'] )) {
	$gait_speed = $_POST ['gait_speed'];
} else {
	$gait_speed = '';
}
if (isset ( $_POST ['climb'] )) {
	$climb = $_POST ['climb'];
} else {
	$climb = '';
}
if (isset ( $_POST ['climb_speed'] )) {
	$climb_speed = $_POST ['climb_speed'];
} else {
	$climb_speed = '';
}
if (isset ( $_POST ['rise'] )) {
	$rise = $_POST ['rise'];
} else {
	$rise = '';
}
if (isset ( $_POST ['spas_hip'] )) {
	$spas_hip = $_POST ['spas_hip'];
} else {
	$spas_hip = '';
}
if (isset ( $_POST ['spas_knee'] )) {
	$spas_knee = $_POST ['spas_knee'];
} else {
	$spas_knee = '';
}
if (isset ( $_POST ['weakness_hip'] )) {
	$weakness_hip = $_POST ['weakness_hip'];
} else {
	$weakness_hip = '';
}
if (isset ( $_POST ['weakness_foot'] )) {
	$weakness_foot = $_POST ['weakness_foot'];
} else {
	$weakness_foot = '';
}
if (isset ( $_POST ['lowerlimbs'] )) {
	$lowerlimbs = $_POST ['lowerlimbs'];
} else {
	$lowerlimbs = '';
}
if (isset ( $_POST ['relatedsymptoms'] )) {
	$relatedsymptoms = $_POST ['relatedsymptoms'];
} else {
	$relatedsymptoms = '';
}
if (isset ( $_POST ['BBfunction'] )) {
	$BBfunction = $_POST ['BBfunction'];
} else {
	$BBfunction = '';
}

$hash_SPRS = array (
		"form" => $_SESSION ['form'],
		"walk" => $walk,
		"gait" => $gait,
		"gait_speed" => $gait_speed,
		"climb" => $climb,
		"climb_speed" => $climb_speed,
		"rise" => $rise,
		"spas_hip" => $spas_hip,
		"spas_knee" => $spas_knee,
		"weakness_hip" => $weakness_hip,
		"weakness_foot" => $weakness_foot,
		"lowerlimbs" => $lowerlimbs,
		"relatedsymptoms" => $relatedsymptoms,
		"BBfunction" => $BBfunction 
);

foreach ( $hash_SPRS as $key => $value ) {
	if ($key != '') {
		$value = mysql_real_escape_string ( $value );
		// ~ $value = mysqli_real_escape_string($link,$value);
		$value = str_replace ( ',', '.', $value );
		$query_update_form = "UPDATE `" . $db . "`.`sprs` SET `$key` = '$value' WHERE `sprs`.`form` = " . $_SESSION ['form'];
		// echo $query_update_form;
		mysql_query ( $query_update_form ) or die ( "impossible d'updater la form : " . mysql_error () );
		// ~ mysqli_query($query_update_form) or die("impossible d'updater la form : " . mysql_error());
	}
}

?>
